﻿using FairyGUI;

/// <summary>
/// 个人资料
/// </summary>
public class UIHome_PersonDetails : UIPopupWindow {

    public UIHome_PersonDetails()
    {
        // 加载界面
        base.Init(UIPackage.CreateObject("主界面", "个人资料").asCom);

        // 初始化关闭按钮
        GButton closeBtn = uiComp.GetChild("关闭按钮").asButton;
        closeBtn.onClick.Add(() => {
            DebugInfo.Log("关闭个人资料");

            AudioController.inst.PlayUIClickEffect();
            uiComp.RemoveFromParent();
            uiComp.Dispose();
            base.Close();
        });

        UserInfo userInfo = DataKernel.inst.userInfo;

        UIHeadpicImage headpicImg = new UIHeadpicImage(uiComp.GetChild("头像").asCom);
        headpicImg.SetHeadpic(userInfo.headpic);

        GTextField nameCtrl = uiComp.GetChild("名字").asTextField;
        nameCtrl.text = "昵称：" + userInfo.name;

        GTextField idCtrl = uiComp.GetChild("编号").asTextField;
        idCtrl.text = "ID：" + userInfo.uid;

        GTextField sexCtrl = uiComp.GetChild("性别").asTextField;
        sexCtrl.text = "性别：" + ((userInfo.sex == 1) ? "男" : "女");

		GTextField diquCtrl = uiComp.GetChild("地区").asTextField;
		diquCtrl.text = "地区：" + userInfo.getProvince();
    }

    /// <summary>
    /// 弹出窗口
    /// </summary>
    public static void Popup()
    {
        DebugInfo.Log("打开个人资料");
        UIRootController.inst.PopupWindow(new UIHome_PersonDetails());
    }
}
